package com.wxyzz.satserver.area.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wxyzz.common.core.entity.Area;
import com.wxyzz.satserver.area.VO.AreaName;
import com.wxyzz.satserver.area.dao.AreaDao;
import com.wxyzz.satserver.area.service.AreaServce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * --- 加油，努力 ---
 *
 * @Author XYP
 * @Date 2024/11/10
 * @Solgne 从想做到能做
 * @Desc
 */
@Service
public class AreaServceImpl implements AreaServce {
    @Autowired
    private AreaDao areaDao;

    @Override
    public List<AreaName> selectAllName() {
        List<Area> areasNameList = areaDao.selectList(new LambdaQueryWrapper<Area>().select(Area::getId, Area::getName));
        List<AreaName> areaNames = new ArrayList<>();
        for (Area areaName : areasNameList) {
            AreaName area = new AreaName();
            area.setId(areaName.getId());
            area.setName(areaName.getName());
            areaNames.add(area);
        }
        return areaNames;
    }

    @Override
    public Area selectById(Integer id) {
        Area area = areaDao.selectById(id);
        return area;
    }
}
